<template>
  <div class="news-info">
    <!-- 面板 -->
    <van-panel :desc="info.add_time">
      <template #header>
        <div class="my-header">
          <h1>{{info.zhaiyao}}</h1>
          <span>阅读{{info.click}}</span>
        </div>
      </template>
      <div class="content">{{info.content}}</div>
    </van-panel>
    <!-- 评论组件 -->
    <Comment :id="id"></Comment>
  </div>
</template>
<script>
import Comment from '@/components/Comment'
export default {
  name: 'NewsInfo',
  props: ['id'],
  data: () => ({
    info: {}
  }),
  // 只执行一次
  created() {
    this.getNewsInfoById()
  },
  methods: {
    async getNewsInfoById() {
      const res = await this.$http.getNewsInfoById(this.id)
      this.info = res.message
    }
  },
  components: {
    Comment
  }
}
</script>
<style lang="less" >
.news-info {
  padding: 0 10px;
  .my-header {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    h1 {
      font-size: 14px;
      padding: 0;
      margin: 0;
    }
    span {
      font-size: 12px;
      color: #646566;
    }
  }
  .van-cell__title,
  .van-cell__value {
    flex: none;
  }
  .van-cell__title {
    font-size: 14px;
    font-weight: 600;
  }
  .van-field__label {
    span {
      font-size: 16px;
      font-weight: 600;
    }
  }
  .van-cell {
    justify-content: space-between;
  }
  .content {
    font-size: 12px;
    text-indent: 2em;
  }
}
</style>